GBML manual / Screen

overlay_start

Plays an overlay effect: a screen effect you made in the Overlay Effects tab, such as Lightning, Heat haze or Teleport. It changes the screen row by row, and moves, pulses or stands still the way the effect says. Only one overlay plays at a time: starting another one replaces the first. overlay_start(nothing) stops it. Give the optional last argument layer (ROOM_LAYER_MAIN, ROOM_LAYER_FRONT or ROOM_LAYER_BACK) to play it on that one tile layer only: overlay_start(ov_haze, ROOM_LAYER_BACK) hazes the Back layer and leaves the Main and Front layers as they are. An effect that changes the whole screen (a Sky color, a Brightness with a color, an Area) is not cut to a layer. With no layer the call is the call it always was.

Works differently on Game Boy - The Game Boy plays an overlay effect in its closest way: the screen fades through its 4 shades, the picture waves line by line, the sky color becomes bands of shades, and a shape wipes in blocks; See-through does nothing.

Works differently on Game Boy Color - The Game Boy Color plays an overlay effect in its closest way: the screen fades with a color, the picture waves line by line, the sky color runs row by row, and a shape wipes in from its left side; See-through does nothing.

Works differently on Sega Genesis - The Sega Genesis plays an overlay effect its own way. This version plays the effects that take the whole screen toward one color (a Brightness with a color) and the Sky color track (the backdrop's color, line by line) and the Wobble track (the picture pushed sideways line by line, both of the console's layers), and a Brightness with no color that is the same on every row (toward black or white, whole sixteenths: the whole palette goes with it, the sky's colors too, and so does a sprite, where the Advance leaves one that is not marked see-through alone) and the Tint track (one color of the room's first picture or tile sheet, line by line: the console changes that color of its palette, so a sprite that draws with the same color in the same palette changes with it; a picture that uses several palettes, or whose colour the console shows as the same as another, is refused with a message that names it); a Wobble with an Area is kept to the rows of the Area (see overlay_area); an effect with another track (See-through, Stretch, Blocks, Shape and the rest), a Brightness that differs from row to row, or an Area beside a track other than the Wobble is refused with a message that names it.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

overlay_start(effect, layer = ROOM_LAYER_ALL)

Arguments

NameType
effectoverlay
layerroom_layer (can be left out; then it is ROOM_LAYER_ALL)

Returns

Nothing.

Description

Plays an overlay effect: a screen effect you made in the Overlay Effects tab, like Lightning, Heat haze, Spotlight or Night falls. It changes the screen row by row and moves, pulses or stands still the way the effect says. overlay_start(nothing) stops it.

Only one overlay plays at a time. Starting another one stops the first.

What it changes

An overlay does not draw anything of its own. In this version no overlay uses one of the console's four background layers (except a box Area that cuts a Wobble or a Stretch, which draws a copy of the room's layer: see Overlay effects). It changes how the console treats what you already have, so what it changes is whatever you marked for it:

TrackWhat it changes
See-throughhow much of the layers and sprites marked see-through shows (background_see_through, sprite_see_through, a dark room's shroud, a room's Tile fade)
Blockshow big the blocks are on what is marked blocky (background_blocky, sprite_blocky, a room's Tile blocks)
Wobble, Stretchpush the first two backgrounds of the room sideways and up or down: a room's own tiles first, then the ones you made with background_create
Sky colorchanges the backdrop color row by row
Tintchanges one color of the first background's palette row by row
Brightnesspushes the backdrop color, a room's own tiles, the layers marked see-through and the sprites marked see-through toward white or black. A sprite you did not mark keeps its colors
Shapesays where See-through and Brightness apply: inside the shape, or everywhere outside it. overlay_focus moves it

An effect can have a See-through track or a Brightness track, never both: the console does one or the other on a screen.

One tile layer

Give it a second argument, the layer, and the effect plays on that one tile layer of the room only: ROOM_LAYER_MAIN, ROOM_LAYER_FRONT or ROOM_LAYER_BACK. Its Wobble, Stretch, Tint, See-through and Brightness rows, its Blocks and its Shape reach only that layer; the other layers, the sprites and the backdrop are left alone. With no layer the call is the call it always was. A room that does not have that layer gives the effect nothing to change.

An effect that changes the whole screen is not cut to a layer, and the Room Editor grays it for a layer: a Sky color (it paints the backdrop behind every layer), a Brightness with a color (it fades every picture and sprite), an Area, a transition, and a Tint in a room that has more than one tile layer (the layers of a room share one palette, so the Tint would color all of them). Only one overlay effect plays at a time, on a layer or not. In the Room Editor, the Effect of a tile layer (Project effects) starts the effect when the room loads, and the canvas plays it live on that layer.

For example, overlay_start(ov_doc_flash, ROOM_LAYER_BACK) plays the effect on the Back layer only.

On the Game Boy Advance

An overlay costs one of the console's 8 row-by-row effects for each track it has (and for each shape, and for each of the two backgrounds a Wobble or a Stretch reaches), shared with everything else that works row by row. A room change keeps two of the eight for itself. If there is no room for one more, a development build stops and says what is holding them; a release build plays the rest of the effect.

An overlay lasts until you stop it, until a pulse that plays once has ended, or until a room is loaded (a restart counts). A pulse that holds lasts until you stop it. A transition is the one overlay that lasts through a room change, because it is what hides it. It shares the screen's one see-through setting and one block size with screen_blend and screen_mosaic: whichever you call last wins, and a pulse calls again every frame.

A game that never plays an overlay has none of this in its cartridge.

Example

overlay_start(ov_doc_flash);

The effect starts at once and plays until it ends by itself.

On the GBA

An overlay changes how the console draws what you already have, row by row. Its See-through track changes how much of the layers and sprites marked see-through shows (a shrouded room’s dark layer, background_see_through, sprite_see_through, a room’s Tile fade); its Blocks track changes the block size of what is marked blocky (background_blocky, sprite_blocky, a room’s Tile blocks); its Brightness track pushes the backdrop color, the room’s own tile layers, the layers marked see-through and the sprites marked see-through (sprite_see_through; a sprite you did not mark keeps its colors) toward white or black; its Wobble and Stretch tracks push the first two backgrounds of the room (its own tile layers first, then the ones made with background_create) sideways and up or down; its Sky color track changes the backdrop color; its Tint track changes one color of the first background’s palette; and its Shape track, with up to two shapes, says where See-through and Brightness apply: inside the shape, or everywhere outside it (a spotlight; overlay_focus moves it). A transition’s shape hides everything inside it, sprites too. An effect can have a See-through track or a Brightness track, not both: the console does one or the other on a screen. No effect makes a background layer of its own, so none of them uses one of the console’s 4 background layers. It costs one of the console’s 8 row-by-row (H-Blank) effects for each track it has (and each shape, and one for each of the two backgrounds a Wobble or a Stretch reaches), shared with everything else that works row by row; a room change keeps two of the eight for itself, so an effect that needs more than six is refused when you check the game. A pulse works its tracks out again every frame (about 5 KB of the console’s big, slow memory, once a game plays an overlay). The overlay lasts until you stop it, until a pulse that plays once has ended, or until a room is loaded (a restart counts). A transition is an overlay too, and the one overlay that lasts through a room change, because it is what hides it. It shares the screen’s one see-through setting and one block size with screen_blend and screen_mosaic: whichever you call last wins, and a pulse calls again every frame. A game that never plays an overlay has none of this in its cartridge. If there is no room for another row-by-row effect, a development build stops with a message that names what holds them; a release build plays the rest of the effect.

See also: Overlay effects - screen effects you make yourselfoverlay_stopoverlay_activeoverlay_focusoverlay_areaoverlay_area_followscreen_blendscreen_mosaicbackground_lookbackground_see_throughbackground_blocky